﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ThinggoWorlducUtils;
using System.Net;
using System.IO;
using System.Threading;
using System.Collections.Specialized;

namespace WorlducClient
{
    public partial class FrmIssueArticle : Form
    {
        public WorlducUtils utils {get;set;}

        public FrmIssueArticle()
        {
            InitializeComponent();            
        }

        //显示数据
        private void SetText(string s)
        {
            txtHint.Text += Environment.NewLine + s;
        }

        private void EnableButton(Button btn)
        {
            btn.Enabled = true;
        }
        
        private void picCheckCode_Click(object sender, EventArgs e)
        {
            string url = "http://www.worlduc.com/plugin/check_code.aspx?t="+DateTime.Now.Ticks;
            picCheckCode.Image = utils.HttpGetImg(url);
        }

        private void btnUploadImg_Click(object sender, EventArgs e)
        {
            string html = utils.HttpGet("http://www.worlduc.com/SpaceManage/Blog/PostBlog.aspx?sid=16");
            OpenFileDialog dlgOpen = new OpenFileDialog();
            if (dlgOpen.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                string txt = utils.UploadImage(dlgOpen.FileName);
                txtHint.Text = txt;
            }
        }

        //发文章
        private void btnIssue_Click(object sender, EventArgs e)
        {            
            txtHint.Text = utils.PostArticle2(txtCheckCode.Text,txtTitle.Text,txtTag.Text,txtContent.Text,txtAttatch.Text);

        }

        private void btnSelect_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlgOpen = new OpenFileDialog();
            if (dlgOpen.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                txtAttatch.Text = dlgOpen.FileName;
            }
        }
    }
}
